<!doctype html>
<html>
	<head>
		<meta charset="UTF-8">
		<title></title>
		<meta name="viewport" content="width=device-width,initial-scale=1,minimum-scale=1,maximum-scale=1,user-scalable=no" />
		<link href="../css/mui.min.css" rel="stylesheet" />
		<link rel="stylesheet" href="../css/style.css" />
		<script src="../js/head_public.js"></script>
		<style>
			.yirenzheng{background:#ff7e00;border-radius: 0.5rem;border: none!important;color: #fff!important;margin-top: 0.8rem;}
		    .gengxin{font-size: 0.3rem;color: #666;margin-top: 0.8rem;display: inline-block;}
		    .ding-code{font-size: 14px;color: #666666;border-bottom: 1px solid #EEEEEE;}
		    .ds-name{padding-left: 40px;font-size: 0.35rem;font-weight: normal;color: #323232;background: url(../images/shaoshi-icon.png)no-repeat;background-size: 30px;background-position: 0rem -0.1rem;margin: 0px;height: 25px;line-height: 25px;}
		    .ds-container{overflow: hidden;margin-top:0.2rem ;position: relative;}
			/*.yirenzheng{background:#ff7e00;border-radius: 0.5rem;border: none!important;color: #fff!important;margin-top: 0.8rem;}*/
		    /*.gengxin{font-size: 0.3rem;color: #666;margin-top: 0.8rem;display: inline-block;margin-left: 0.5rem;}*/
		</style>
	</head>

	<body>
		<header class="mui-bar mui-bar-nav ding-bar">
		    <a class="mui-action-back mui-icon mui-icon-left-nav mui-pull-left"></a>
		    <h1 class="mui-title">待收货</h1>
		</header>
		<div class="mui-content">
			<div id="pullrefresh" class="newslist w620 mui-scroll-wrapper" style="position: static;">
    		<ul class="store-list dt-order-list" id="list">
	    		<!--<li>
	    			<a style="display: block;">
	    				<h2 class="ds-name store_name">兰州新辉商店</h2>
	    				<div class="ding-code">订单编号：1234567894561233</div>
	    				<div class="ds-container">
	    					<img  src="../images/goods.png"/>
		    				<div class="store-con">
		    					<h1 class="only-line" style="overflow: hidden;">兰州新辉商店<span class="order-p">￥19.9</span></h1>
		    					<span class="gengxin">共1件商品</span><span class="shifu">实付：<b>￥19.7</b></span>
		    					<!--<img src="../images/phone.png"  class="gm-phone-icon"/>-->
		    				     <!--<span class="gm-phone-icon" style="color: #666666;">x1</span>-->
		    				<!--</div>-->
	    				<!--</div>-->
	    				<!--<div class="ds-container">-->
	    					<!--<img  src="../images/goods.png"/>-->
		    				<!--<div class="store-con">-->
		    					<!--<h1 class="only-line" style="overflow: hidden;">兰州新辉商店<span class="order-p">￥19.9</span></h1>-->
		    					<!--<span class="gengxin">共1件商品</span><span class="shifu">实付：<b>￥19.7</b></span>-->
		    					<!--<img src="../images/phone.png"  class="gm-phone-icon"/>-->
		    				     <!--<span class="gm-phone-icon" style="color: #666666;">x1</span>-->
		    				<!--</div>-->
	    				<!--</div>-->
	    			<!--</a>-->
	    			<!--<div class="lookinfo">-->
	    				<!--<img src="../images/lookinfo.jpg" />-->
	    			<!--</div>-->
	    		<!--</li>-->
	    		
	    	</ul>	
		    </div>
		</div>
		<script src="../js/mui.min.js"></script>
		<script src="../js/jquery-1.8.0.min.js"></script>
		<script src="../js/session.js"></script>
		<script src="../js/common.js"></script>
		<script type="text/javascript">
		mui(".store-list").on("tap",".store_name",function(){
			mui.openWindow({url:$(this).attr("data-href")})
		})
		mui(".store-list").on("tap",".ds-container",function(){
			mui.openWindow({url:$(this).attr("data-href")})
		})
		mui(".store-list").on("tap",".ckxq-btn",function(){
			mui.openWindow({url:$(this).attr("data-href")})
		})
	    mui.init({
			pullRefresh: {
				container: '#pullrefresh',
				down: {
					style:'circle',
					callback: pulldownRefresh
				},
				up: {
					contentrefresh: '正在加载...',
					callback: pullupRefresh
				}
			}
		});
		/**
		 * 下拉刷新具体业务实现
		 */
		function pulldownRefresh() {
			setTimeout(function() {
				mui('#pullrefresh').pullRefresh().endPulldownToRefresh();
				getContents();
			}, 1500);
		}
		/**
		 * 上拉加载具体业务实现
		 */
		function pullupRefresh() {
			setTimeout(function() {
				mui('#pullrefresh').pullRefresh().endPullupToRefresh(); //参数为true代表没有更多数据了。
				getContents();
			}, 1500);
		} 
		    var page=1;
			var userid=getCookie("userid")
			if(userid==""||userid==null){
				alert("您还没有登录，请先登录")
				location.href="../public/login.html"
			}else{

                    getContents()
//                          确认收获
                mui(".store-list").on("tap",".qrsh-btn",function(){
					var id = $(this).attr("data-id");
					var data={};
					data.member_id=userid;
					data.order_id=id;
					data.state_type="order_receive";
					$.post(net+"/public/index.php?s=api/memberorder/change_state/",data,function(){
						alert("收货成功");
						location.reload();
					})
				})
			}
						
		
	    function getContents(){
	    		var params={};
				params.member_id=userid;
				params.state_type="30";
				params.page=page;
				$.post(net+"/public/index.php?s=api/Memberorder/member_order/",params,function(res){
					if(res.code=="200"){
						if(res.result!=null&&res.result!=''){
							var str="";
							$.each(res.result, function() {
								if(this.order_list!=null&&this.order_list.length!=0){
									$.each(this.order_list, function(index,val1) {
										var goolist="";
										var heji="";
										if(this.goods_list!=null&&this.goods_list.length!=0){
											$.each(this.goods_list, function(index,val) {
												var price="";
												var shifu="";
												shifu='<span class="shifu"><b style="color:#666;font-size:14px">'+val1.payment_name+'</b></span>'
												if(val1.payment_code=="point"){
													heji=val1.order_point+"积分";
													price = '<span class="order-p">'+this.goods_point+'积分</span>'
												}else{
													heji="￥"+val1.order_amount;
													price = '<span class="order-p">￥'+this.goods_price+'</span>'
												}
												var src=net+"public/uploads/home/store/goods/"+this.store_id+"/"+this.goods_image;
												goolist+='<div class="ds-container" data-href="shangpininfo.html?id='+this.goods_id+'"><img  src="'+src+'"/><div class="store-con"><h1 class="only-line" style="overflow: hidden;">'+this.goods_name+price+'</h1>'
											            +'<span class="gengxin">共'+this.goods_num+'件商品</span>'+shifu+'<span class="gm-phone-icon" style="color: #666666;">x'+this.goods_num+'</span></div></div>'
											});
										}
									     str+='<li><a style="display: block;"><h2 class="ds-name store_name" data-href="info.html?id='+this.store_id+'">'+this.store_name+'</h2>'
									        +'<div class="ding-code">订单编号：'+this.order_sn+'</div>'
			    			                +goolist
			    			                +'</a><div class="lookinfo" ><div style="overflow:hidden;margin-top:5px;text-align:left;font-size:14px"><span>实付:</span><span style="color:#ff7e00">'+heji+'</span></div><button  class="ckxq-btn" data-href="order-info.html?id='+this.order_id+'" >查看详情</button><button  class="qrsh-btn" style="margin-right:20px" data-id="'+this.order_id+'">确认收货</button></div></li>'
									});
									
								} 
							});
                            $("#list").append(str)
                        page++;
                   }
				}
			})
	    }
		</script>
	</body>

</html>